package me.lc.linklink.core;

import me.lc.linklink.entity.AssertInfo;
import me.lc.linklink.util.GsonHelper;
import me.lc.linklink.util.ShareSettingUtil;

/**
 * 道具和商店管理器
 * 
 * @author Administrator
 * 
 */
public class ShopManager {
	public static ShopManager instance = new ShopManager();

	public AssertInfo assertInfo;

	private static final String ASSERT_INFO = "MyAssert";

	private ShopManager() {
		
	}

	public void saveMyAssert() {
		ShareSettingUtil.storeStringSetting(ASSERT_INFO,
				GsonHelper.getJsonString(assertInfo));
	}

	public void init() {
		String assertStr = ShareSettingUtil.getStringSetting(ASSERT_INFO);
		if (assertStr.equalsIgnoreCase("null")) {
			setDefault();
		} else {
			assertInfo = (AssertInfo) GsonHelper.getObjectbyJsonString(
					assertStr, AssertInfo.class);
		}
	}

	private void setDefault() {
		assertInfo = new AssertInfo();
		assertInfo.setMoney(500);
		assertInfo.setFinderCount(2);
		assertInfo.setReArrangeCount(1);
		assertInfo.setTimerCount(1);
		saveMyAssert();
	}
}
